package com.jzo2o.customer.controller.agency;

import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.service.IBankAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author SpongeBob
 */
@RestController("agencyBankAccountController")
@Api(tags = "机构端 - 银行账户相关接口")
@RequestMapping("/agency/bank-account")
@RequiredArgsConstructor()
public class BankAccountController {
    private final IBankAccountService bankAccountService;

//    接口名称: 新增或更新银行账号信息
//    接口路径：POST/customer/agency/bank-account
//    请求类型：application/json

    @PostMapping
    @ApiOperation("新增或更新银行账号信息")
    public BankAccountResDTO addBankAccount(@RequestBody BankAccountUpsertReqDTO bankAccountDTO) {
        return bankAccountService.saveBank(bankAccountDTO);
    }

//    5.4.2 获取当前用户银行账号接口
//    接口名称：获取当前用户银行账号
//    接口功能：进入账户设置界面会先查询当前用户的账户信息，如果已经设置则显示在页面中。
//    接口路径：GET/customer/agency/bank-account/currentUserBankAccount

    @GetMapping("/currentUserBankAccount")
    @ApiOperation("获取当前用户银行账号")
    public BankAccountResDTO currentUserBankAccount() {
        return bankAccountService.getBank();
    }
}
